package de.fhaugsburg.games.boardgames.scrabble.application;

import de.fhaugsburg.games.boardgames.scrabble.IScrabbleEngine;
import de.fhaugsburg.games.boardgames.scrabble.ScrabbleEngine;
import de.fhaugsburg.games.boardgames.scrabble.ScrabbleLetterSack;
import de.fhaugsburg.games.boardgames.scrabble.WordManager;
import de.fhaugsburg.games.boardgames.scrabble.consoleui.BoardView;
import de.fhaugsburg.games.boardgames.scrabble.consoleui.CommandProcessor;
import de.fhaugsburg.games.boardgames.scrabble.consoleui.IGuiMessage;
import de.fhaugsburg.games.boardgames.scrabble.logging.LoggingHandler;
import de.fhaugsburg.games.boardgames.scrabble.scrabbleboard.ScrabbleBoard;
import de.fhaugsburg.games.boardgames.scrabble.terminal.TerminalServer;

public class ScrabbleLauncher {

	

	public static void main(String[] args) {
		ScrabbleBoard gameBoard = new ScrabbleBoard();
		BoardView gameView = new BoardView(gameBoard);
		
		//initialize engine and surround it by proxy for logging
		//IScrabbleEngine gameEngine = new ScrabbleEngine(gameBoard);
		IScrabbleEngine gameEngine = new ScrabbleEngine(gameBoard, new ScrabbleLetterSack(), new WordManager(gameBoard));
		
		//LoggingHandler factory to do all the nasty invocation + logging stuff
		IScrabbleEngine engineProxy = LoggingHandler.scrabbleEngineLogginProxy(gameEngine);
		
		//create TerminalServer
		TerminalServer terminalServer = new TerminalServer(4);
		
		//commandline interface for the engine
		CommandProcessor gameProcess =  new CommandProcessor(engineProxy, gameView, terminalServer);

		//register reference to user interface for engine to interact
		engineProxy.registerGui((IGuiMessage) gameProcess);
		
		//run the game
		gameProcess.process();
	}
}
